<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class GameRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $method = request()->getMethod();
        $rules = [
            'platform' => 'required',
            /*'suppliers' => 'required',*/
            'game_id' => 'required',
            'note' => 'max:100'
        ];
        if ($method == 'PUT'){
            unset($rules['platform']);
            unset($rules['suppliers']);
            unset($rules['game_id']);
        }
        return $rules;
    }

    public function messages()
    {
        return [
            'platform.required' => '请选择手机平台',
            /*'suppliers.required' => '请选择游戏供应商',*/
            'game_id.required' => '请输入游戏名称',
            'note.max' => '备注最多输入100个字符',
        ];
    }
}
